package com.example.shiwuyouproject.ui.modelview

import androidx.lifecycle.MutableLiveData
import com.example.shiwuyouproject.base.BaseViewModel
import com.example.shiwuyouproject.ui.fragment.home.bean.GetHomeDashboardBean
import com.example.shiwuyouproject.ui.fragment.home.bean.HomeRecommendListDataBean
import com.example.shiwuyouproject.ui.fragment.my.activity.bean.MyApplicationBean

class HomeViewModel:BaseViewModel() {
    private val loginRepository by lazy { RetrofitClient.getApiService() }
    /**
     * 首页-获取首页数据
     */
    val getHomeDashboardStatus = MutableLiveData<GetHomeDashboardBean>()
    fun getHomeDashboard(){
        launch(
            block = {
                val codeStatus = loginRepository.getHomeDashboard()
                getHomeDashboardStatus.value=codeStatus.result()
            },
            error = {
            },
            cancel = {

            },
            showErrorToast = false
        )
    }

    val getHomeRecommendList = MutableLiveData<MutableList<HomeRecommendListDataBean>>()
    fun getCommissionLists(page:String){
        launch(
            block = {
                val codeStatus = loginRepository.getHomeRecommend("510700",page)
                getHomeRecommendList.value=codeStatus.result().data
            },
            error = {
            },
            cancel = {

            },
            showErrorToast = false
        )
    }
}